package com.jade.editor.domain.parts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

public class StatusBar {
	
	
	public StatusBar(final Composite parent, DrawArea drawArea){
		int x = 0;
		int y = 0;
		
		final Composite statusBar = new Composite(parent, SWT.NONE);
		statusBar.setBounds(0, 635, 700, 18);
		statusBar.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
		
		final Label statusLabel = new Label(statusBar, SWT.NONE);
		statusLabel.setBounds(10, 3, 300, 15);
		statusLabel.setText("Mouse coords: x = " + x + "; y = " + y);
		
		final Label separatorH1 = new Label(statusBar, SWT.SEPARATOR | SWT.HORIZONTAL);
		separatorH1.setBounds(0, 1, 600, 2);
		
		final Label zoomLabel = new Label(statusBar, SWT.NONE);
		zoomLabel.setBounds(621, 3, 80, 15);
		zoomLabel.setText("Zoom: 100%");
		
		parent.addControlListener(new ControlAdapter() {
		@Override
		public void controlResized(final ControlEvent e) {
			statusBar.setBounds(0, parent.getSize().y - 18, parent.getSize().x, 18);
			separatorH1.setBounds(0, 1, parent.getSize().x, 2);
			zoomLabel.setBounds(parent.getSize().x - 80, 3, 80, 15);
			}
	    });
		
		drawArea.getDrawAreaComposite().addMouseMoveListener(new MouseMoveListener() {
			public void mouseMove(MouseEvent e) {
				statusLabel.setText("Mouse coords: x = " + e.x + "; y = " + e.y);
			}
		});
	}

}
